import type { TreeDataItem } from "ant-design-vue/es/tree"
import { ContextMenuItem } from "/@/hooks/web/useContextMenu"
export interface ActionItem {
  render: (record: Recordable) => any
  show?: boolean | ((record: Recordable) => boolean)
}

export enum ToolbarEnum {
  RELOAD,
  SELECT_ALL,
  UN_SELECT_ALL,
  EXPAND_ALL,
  UN_EXPAND_ALL,
  CHECK_STRICTLY,
  CHECK_UN_STRICTLY,
}

export interface TreeItem extends TreeDataItem {
  icon?: any
  id?: string
  pId?: string
  name?: string
  children?: TreeItem[]
}

export interface FieldNames {
  children?: string
  title?: string
  key?: string
}

export type Keys = (string | number)[]
export type CheckKeys = (string | number)[] | { checked: (string | number)[]; halfChecked: (string | number)[] }

export interface TreeActionType {
  checkAll: (checkAll: boolean) => void
  expandAll: (expandAll: boolean) => void
  setExpandedKeys: (keys: Keys) => void
  getExpandedKeys: () => Keys
  setSelectedKeys: (keys: Keys) => void
  getSelectedKeys: () => Keys
  getHalfCheckedKeys: () => Keys
  setCheckedKeys: (keys: CheckKeys) => void
  getCheckedKeys: () => CheckKeys
  filterByLevel: (level: number) => void
  insertNodeByKey: (opt: InsertNodeParams) => void
  insertNodesByKey: (opt: InsertNodeParams) => void
  deleteNodeByKey: (key: string) => void
  updateNodeByKey: (key: string, node: Omit<TreeDataItem, "key">) => void
  setSearchValue: (value: string) => void
  getSearchValue: () => string
  setTreeData: (treeData: Recordable[] | undefined) => void
  reload: () => void
}

export interface InsertNodeParams {
  parentKey: string | null
  node: TreeDataItem
  list?: TreeDataItem[]
  push?: "push" | "unshift"
}

export interface ContextMenuOptions {
  icon?: string
  styles?: any
  items?: ContextMenuItem[]
}
